<?php
/**
 * wp-foundation header-extensions.php
 */
function foundation_pre_container_build(){
global $options; foreach ($options as $value) { if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }}
	?>
	<div id="wrapper">
	
	<?php foundation_aboveheader(); //hook
		if ($fd_nav_placement == 'Above Header'){
			foundation_top_nav();
		}
		if ($fd_home_banner_location == 'Above Header'){
			foundation_home_splash();
		}
		if ($fd_custom_search == "Enable" && $fd_custom_search_placement == "Above Header"){
			foundation_custom_search();
		}
	?>
	
	<header id="header">
		
	<?php foundation_header(); //hook ?>
		
	<div id="title-description-wrap" class="wrapper">
	
	<?php if ($fd_logo_insert == 'Show'){ ?>
		<div id="logo">
			<a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home">
				<img src="<?php echo $fd_logo_image_url; ?>" alt="<?php echo $fd_logo_image_alt; ?>" title="<?php echo $fd_logo_image_title; ?>" />
			</a>
		</div>
	<?php } ?>
	
	<?php if ($fd_site_title_toggle == 'Show'){ ?>	
		<div id="site-title">
			<span>
				<a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home"><?php bloginfo('name') ?></a>
			</span>
		</div>
	<?php } ?>
	
	<?php if ($fd_site_description_toggle == 'Show'){
		if (is_home() || is_front_page()) { ?>
			<h1 id="site-description"><?php bloginfo('description') ?></h1>
		<?php } else { ?>	
			<div id="site-description"><?php bloginfo('description') ?></div>
		<?php 
		}
	}
	?>
	
	</div><!--  .eof title-description-wrap -->
	
	<?php
		if ($fd_nav_placement == 'Inside Header'){
			foundation_top_nav();
		}
		if ($fd_custom_search == "Enable" && $fd_custom_search_placement == "Inside Header"){
			foundation_custom_search();
		}
	?>
	<?php foundation_header_bottom(); //hook ?>
	</header><!-- .eof header -->
	
	<?php foundation_belowheader(); //hook
		if ($fd_home_banner_location == 'Below Header'){
			foundation_home_splash();
		}
		if ($fd_nav_placement == 'Below Header'){
			foundation_top_nav();
		}
		if ($fd_custom_search == "Enable" && $fd_custom_search_placement == "Below Header"){
			foundation_custom_search();
		}
		foundation_belowsplash(); //hook
	?>
	
	<div id="main">
	<div class="wrapper">
	
	<?php
}
add_filter('foundation_pre_container_area', 'foundation_pre_container_build', 1);


function foundation_pagetitle(){
	if ( is_single() ) { single_post_title(); }      
	elseif ( is_home() || is_front_page() ) { bloginfo('name'); print ' | '; bloginfo('description'); get_page_number(); }
	elseif ( is_page() ) { single_post_title(''); }
	elseif ( is_search() ) { bloginfo('name'); print ' | Search results for ' . wp_specialchars($s); get_page_number(); }
	elseif ( is_404() ) { bloginfo('name'); print ' | Not Found'; }
	else { bloginfo('name'); wp_title('|'); get_page_number(); }
}


add_filter('body_class','browser_body_class');
function browser_body_class($classes) {
	$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
	if (preg_match( "/Mac/", $browser ))$classes[] = 'mac';
	elseif (preg_match( "/Windows/", $browser ))$classes[] = 'windows';
	elseif ( preg_match( "/Linux/", $browser ) )$classes[] = 'linux';
	else $classes[] = 'unknown-os';

	if ( preg_match( "/Chrome/", $browser ) ) {
			$classes[] = 'chrome';
			preg_match( "/Chrome\/(\d.\d)/si", $browser, $matches);
			$classesh_version = 'ch' . str_replace( '.', '-', $matches[1] );      
			$classes[] = $ch_version;

	} elseif ( preg_match( "/Safari/", $browser ) ) {
			$classes[] = 'safari';
			preg_match( "/Version\/(\d.\d)/si", $browser, $matches);
			$sf_version = 'sf' . str_replace( '.', '-', $matches[1] );      
			$classes[] = $sf_version;
			
	} elseif ( preg_match( "/Opera/", $browser ) ) {
			$classes[] = 'opera';
			preg_match( "/Opera\/(\d.\d)/si", $browser, $matches);
			$op_version = 'op' . str_replace( '.', '-', $matches[1] );      
			$classes[] = $op_version;
			
	} elseif ( preg_match( "/MSIE/", $browser ) ) {
			$classes[] = 'msie';
			if( preg_match( "/MSIE 6.0/", $browser ) ) {
					$classes[] = 'ie6';
			} elseif ( preg_match( "/MSIE 7.0/", $browser ) ){
					$classes[] = 'ie7';
			} elseif ( preg_match( "/MSIE 8.0/", $browser ) ){
					$classes[] = 'ie8';
			}
			
	} elseif ( preg_match( "/Firefox/", $browser ) && preg_match( "/Gecko/", $browser ) ) {
			$classes[] = 'firefox';
			preg_match( "/Firefox\/(\d)/si", $browser, $matches);
			$ff_version = 'ff' . str_replace( '.', '-', $matches[1] );      
			$classes[] = $ff_version;
			
	} else {
			$classes[] = 'unknown-browser';
	}

	if(is_single()) {
	$category = get_the_category();
	$classes[] .= $category[0]->slug;
	$tag = get_tags();
	$classes[] .= $tag[0]->slug;
}
	return $classes;
}
?>